﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Mobile
    {
        private string brand;
        public string Brand { get { return brand; } set { brand = value; } }
        public Mobile() { }
        public Mobile(string brand)
        {
            this.brand = brand;
        }


    }
    interface IUsb
    {
        void Read();
        void Write();

    }
    class Udisk : Mobile, IUsb
    {
        private string name;
        public string Name { get { return name; } set { name = value; } }
        public Udisk() { }
        public Udisk(string name) : base(name)
        {
            this.name = name;
        }
        public void Read()
        {
            Console.WriteLine("{0}牌子的{1}正在读取", this.Brand, this.name);
        }
        public void Write()
        {
            Console.WriteLine("{0}牌子的{1}正在编写", this.Brand, this.name);
        }

    }
    class MobileDisk : Mobile, IUsb
    {
        private string name;
        public string Name { get { return name; } set { name = value; } }
        public MobileDisk() { }
        public MobileDisk(string name) : base(name)
        {
            this.name = name;
        }

        public void Read()
        {
            Console.WriteLine("{0}牌子的{1}正在读取", this.Brand, this.name);
        }
        public void Write()
        {
            Console.WriteLine("{0}牌子的{1}正在编写", this.Brand, this.name);
        }
    }
    class Computer
    {
        private string brand;
       private IUsb usb1;
        private IUsb usb2;
        public IUsb Usb1 { get {return usb1; } set { usb1 = value; } }
        public IUsb Usb2 { get { return usb2; } set { usb2 = value; } }
        public string  Brand { get {return brand; } set { brand = value; } }
        public Computer() { }
        public Computer(string brand)
        {
            this.brand = brand;
        }

        public void Open() {
            Console.WriteLine("{0}开机中......",this.brand);
        }

        public void ReadData()
        {
            this.Usb1.Read();
            this.Usb1.Write();
        
        }
        public void WriteData()
        {
            this.Usb2.Read();
            this.Usb2.Write();

        }
        public void end() {
            Console.WriteLine("{0}正在关机",this.brand);
        } 

    }
    class Program
    {
        static void Main(string[] args)
        {
            Udisk u1 = new Udisk();
            u1.Brand = "金士顿";
            u1.Name = "U盘";
            u1.Read();
            u1.Write();

            MobileDisk m1 = new MobileDisk();
            m1.Brand = "三星";
            m1.Name = "机械硬盘";


            Console.WriteLine();
            Computer computer = new Computer();
            computer.Brand = "联想";
            computer.Open();
            computer.Usb1 = u1;
            computer.Usb2 = m1;
            computer.ReadData();
            computer.WriteData();
            computer.end();
        }
    }
}
